<template>
    <div>
        <div class="baseform">
            <el-form :label-position="labelPosition" label-width="80px" :model="from">
                <div>
                    <h3>处理</h3>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="违章行为" prop="causeNo">
                                <el-select v-model="from.causeNo" placeholder style="width: 100%">
                                    <el-option
                                            v-for="item in breaklist"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label=" 办理期限" prop="limitTime">
                                <el-date-picker
                                        v-model="from.limitTime"
                                        type="date"
                                        value-format="timestamp"
                                        placeholder="选择日期"
                                        style="width:100%"
                                ></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label=" 紧急程度" prop="emergency">
                                <el-select v-model="from.emergency" placeholder style="width: 100%">
                                    <el-option
                                            v-for="item in levellist"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label=" 投诉类型" prop="complainType">
                                <el-select v-model="from.complainType" placeholder style="width: 100%">
                                    <el-option
                                            v-for="item in complaintlist"
                                            :key="item.id"
                                            :label="item.name"
                                            :value="item.id"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="24">
                            <el-form-item label="处理意见" prop="advice">
                                <!-- <el-input v-model="from.illegallaw"></el-input> -->
                                <el-input
                                        type="textarea"
                                        :autosize="{ minRows: 2, maxRows: 12}"
                                        placeholder="请输入内容"
                                        v-model="from.advice"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
            </el-form>
        </div>
    </div>
</template>
<script>
    import dictCache from "@/assets/utils/cache-dict-util";
    import FormBtns from "@/views/comps/zhzf/form-btns";
    import caseApi from "@/api/system/case";
    import lawuserApi from "@/api/system/lawuser";
    import deptApi from "@/api/system/dept";
    import TreeSelect from "../../comps/zhzf/tree-select";
    // import breakInfo from "./break-info";
    import {mapActions} from "vuex";

    export default {
        components: {FormBtns},
        props: {
            edit: {
                required: true,
                default: false
            },
        },

        data() {
            return {
                labelPosition: "right",
                breaklist:[
                    {
                        id: '1',
                        name: '违法行为1'
                    }, {
                        id: '2',
                        name: '违法行为2'
                    }, {
                        id: '3',
                        name: '违法行为3'
                    }
                ],
                levellist:[
                    {
                        id: '1',
                        name: '一般'
                    }, {
                        id: '2',
                        name: '紧急'
                    }
                ],
                complaintlist:[
                    {
                        id: '1',
                        name: '初次投诉'
                    }, {
                        id: '2',
                        name: '重复投诉'
                    }, {
                        id: '3',
                        name: '一事多投'
                    }
                ],
                from: {}
            };
        },
        methods: {
            ...mapActions("d2admin/page", ["close"]),
            async initPage(detail, distData) {
                this.from = detail;
                this.cartypelist = distData.cartypelist;
                this.from.staffstr = this.stafflistTostr(detail.statffs);
                this.typeList = distData.typeList;
                this.systemList = distData.systemList;
                this.fromList = distData.fromList;
                this.treeList = distData.treeList;
                this.zftypelist = distData.zftypelist;
                this.casetypelist = distData.casetypelist;
                // this.setDefaultData();
                if (this.from.zfml) {
                    this.changeZfml();
                }
            },
            changeZfml() {
                let zfml = dictCache.getDataInfo("0055", this.from.zfml);
                this.from.zfmlName = zfml.name;
                this.$emit("changezfml");
            },
            showDetail(type) {
                this.$refs.breakInfo.initPage(type, this.from);
                //  this.staffList()
            },
            async getbreakdata(data) {
                if (!data) {
                    utils.showTips("请选择数据");
                    return;
                } else {
                    let stafflist = data;
                    this.from.statffs = [];
                    for (var i = 0; i < stafflist.length; i++) {
                        let obj = {};
                        let item = stafflist[i];
                        obj.username = item.username;
                        obj.userId = item.id;
                        obj.realName = item.realname;
                        obj.cardNo = item.orgCode || "12";
                        obj.caseId = item.enabled || "34";
                        obj.caseStaffId = item.operateType || "56";
                        this.from.statffs.push(obj);
                    }
                    this.from.staffstr = this.stafflistTostr();
                    this.$forceUpdate();
                }
            },
            stafflistTostr() {
                let userText = [];
                if (this.from.statffs) {
                    this.from.statffs.forEach(item => {
                        userText.push(item.username);
                    });
                }
                return userText.join(",");
            },
            async staffList() {
                let res1 = await lawuserApi.stafflist();
            },
            setDefaultData() {
                if (!this.from.caseTypeId) {
                    this.from.caseTypeId = Object.values(this.typeList)[0].id;
                }
                if (!this.from.zfml) {
                    this.from.zfml = Object.values(this.zftypelist)[0].id;
                }
                if (!this.from.casestatus) {
                    this.from.casestatus = "未立案";
                }
                if(!this.from.caseType){
                    this.from.caseType = Object.values(this.casetypelist)[0].id;
                }
            },
        }
    };
</script>
<style lang="scss">
    .baseform {
        padding: 0px 20%;
    }
    .el-date-editor {
        .el-input__suffix {
            display: none;
        }
    }
</style>
